package yangyongchao.com.howusingappbar;

import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by yyc on 2018/2/6.
 */

public abstract class BaseActivity extends AppCompatActivity {
    private FrameLayout mFraLayoutContent;
    //Toolbar
    private AppBarLayout mAppBarLayout;
    private TextView mTopLeftTv;
    private TextView mTopRightTv;
    private TextView mTopMiddleTv;
    private Button mTopLeftBtn;
    private Button mTopRightBtn;
    private Button mTopMiddleBtn;
    private ImageView mTopLeftIv;
    private ImageView mTopRightIv;
    private ImageView mTopMiddleIv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(R.layout.base_activity);
        mAppBarLayout = findViewById(R.id.toolbar);
        mFraLayoutContent = findViewById(R.id.fraLayoutContent);
        LayoutInflater.from(this).inflate(layoutResID, mFraLayoutContent, true);
        mTopLeftTv = findViewById(R.id.left_tv);
        mTopRightTv = findViewById(R.id.right_tv);
        mTopMiddleTv = findViewById(R.id.middle_tv);
        mTopLeftBtn = findViewById(R.id.left_btn);
        mTopRightBtn = findViewById(R.id.right_btn);
        mTopMiddleBtn = findViewById(R.id.right_btn);
        mTopLeftIv = findViewById(R.id.left_iv);
        mTopRightIv = findViewById(R.id.right_iv);
        mTopMiddleIv = findViewById(R.id.middle_iv);
    }
    protected void showTopLeftBtn(){
        mTopLeftBtn.setVisibility(View.VISIBLE);
    }
    protected void showTopMiddleTv(){
        mTopMiddleTv.setVisibility(View.VISIBLE);
    }
    protected void setMiddleTv(String str){
        mTopMiddleTv.setText(str);
    }
    protected void showTopRightBtn(){
        mTopRightBtn.setVisibility(View.VISIBLE);
    }
    protected Button getTopLeftBtn(){
        return mTopLeftBtn;
    }
}
